package com.jayam.gas.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class AddOrderViewImpl<T> extends Composite implements AddOrderView<T> {

	@UiTemplate("AddOrderView.ui.xml")
	interface AddOrderViewUiBinder extends UiBinder<Widget, AddOrderViewImpl> {
	}

	private static AddOrderViewUiBinder uiBinder = GWT.create(AddOrderViewUiBinder.class);

	// @UiField HTML contactsTable;
	@UiField
	Button addButton;
	@UiField
	TextBox mobNo;
	@UiField
	TextBox mobNoConfirm;

	private com.jayam.gas.client.view.AddOrderView.Presenter<T> presenter;

	// @UiField Button deleteButton;

	public AddOrderViewImpl() {
		initWidget(AddOrderViewImpl.uiBinder.createAndBindUi(this));
	}

	@Override
	public void setPresenter(final Presenter<T> presenter) {
		this.presenter = presenter;
	}

	@UiHandler("addButton")
	void onAddButtonClicked(final ClickEvent event) {
		if (presenter != null) {
			presenter.onAddButtonClicked();
		}
	}

	@Override
	public Widget asWidget() {
		Window.alert("AddOrderView");
		return this;
	}
}
